<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="${pageContext.request.contextPath}/webjars/jquery/3.7.1/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/webjars/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/webjars/bootstrap/5.1.3/css/bootstrap.min.css"/>
</head>
<body>
<div class="container mt-3">
    <h4>会员等级权益</h4>
    <form action="c_choose.jsp" method="post">
        <select class="form-select" aria-label="Default select example" name="level">
            <option selected>请选择会员等级</option>
            <option value="normal">普通用户</option>
            <option value="silver">银卡会员</option>
            <option value="gold">金卡会员</option>
            <option value="diamond">钻石会员</option>
            <option value="platinum">（测试无效值）白金会员</option>
        </select>
        <button type="submit"  class="btn btn-primary mt-3">查看权益</button>
    </form>
</div>
<hr>
<div class="container mt-3">
    <c:set var="userLevel" value="${param.level}"/>
    <p>当前会员等级：<strong>${empty userLevel ? '未提供' : userLevel}</strong></p>
    <c:choose>
        <c:when test="${userLevel == 'normal'}">
            <h3>普通用户</h3>
            <p>折扣：<span class="discount">无</span></p>
            <p>专属服务：暂无</p>
        </c:when>

        <c:when test="${userLevel == 'silver'}">
            <h3>银卡会员</h3>
            <p>折扣：<span class="discount">95 折</span></p>
            <p>专属服务：免费退换货</p>
        </c:when>

        <c:when test="${userLevel == 'gold'}">
            <h3>金卡会员</h3>
            <p>折扣：<span class="discount">9 折</span></p>
            <p>专属服务：免费退换货 + 优先客服</p>
        </c:when>

        <c:when test="${userLevel == 'diamond'}">
            <h3>钻石会员</h3>
            <p>折扣：<span class="discount">8 折</span></p>
            <p>专属服务：免费退换货 + 优先客服 + 生日礼包 🎁</p>
        </c:when>

        <c:otherwise>
            <p class="error">⚠️ 无效或未知的会员等级：“${userLevel}”</p>
            <p>请确认输入值为：normal / silver / gold / diamond</p>
        </c:otherwise>
    </c:choose>
</body>
</html>
